/*
 * @Author: Clark
 * @Email: haixuanwoTxh@gmail.com
 * @Date: 2023-01-05 11:04:16
 * @LastEditors: Clark
 * @LastEditTime: 2023-01-05 11:27:19
 * @Description: file content
 */

#include "apue.h"

static void charatatime(char *);

int main()
{
    pid_t pid;

    if ((pid = fork()) < 0)
    {
        err_sys("fork error");
    }
    else if (0 == pid)
    {
        charatatime("output from child\n");
    }
    else
    {
        charatatime("output from parent\n");
    }

    exit(0);
}

static void charatatime(char *str)
{
    char *ptr = NULL;
    int c;

    setbuf(stdout, NULL);
    for (ptr = str; (c = *ptr++) != 0;)
    {
        putc(c, stdout);
    }
}
